﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Krist_em_up.Components;

namespace Krist_em_up.Interface
{
    public class Button 
    {
        public EventHandler<EventArgs> Selected;
        protected Vector2 position;
        public Vector2 Position
        {
            get { return position; }
            set { position = value; }
        }

        protected string text;
        public string Text
        {
            get { return text; }
        }

        //protected TextComponent compo;

        protected Color color;
        public Color Color
        {
            get { return color; }
            set { color = value; }
        }
        protected float scale, pulsate;
        public bool IsActive;


        public Button(Vector2 Position, string text)
        {
            position = Position;
            this.text = text;
            Unfocus();
            //compo = new TextComponent(game, "font");
            
        }
        public void OnSelected()
        {
            if(Selected != null)
                Selected(this, new EventArgs());
        }
        public void Update(GameTime gameTime)
        {
            //float fadeSpeed = (float)gameTime.ElapsedGameTime.TotalSeconds * 4;
            //scale = Math.Max(scale + fadeSpeed, 1);
            //double time = gameTime.TotalGameTime.TotalSeconds;

            //pulsate = (float)Math.Sin(time * 6) + 1;
            //scale = 1 + pulsate * 0.05f * scale;
        }

        public void Draw(SpriteBatch sprite, SpriteFont font)
        {
            sprite.Begin();
            sprite.DrawString(font, text, position, color, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            sprite.End();
        }

        internal void Focus()
        {
            color = Color.Red;
            scale = 1.1f;
        }

        internal void Unfocus()
        {
            color = Color.White;
            scale = 0.9f;
        }
        public override string ToString()
        {
            return text;
        }
    }
}
